/* create conflict*/


#include "Player.H"
#include <unistd.h>
#include "Table.H"

void Player::Play()
{
	Run();
}


void Player::ProcessEventQueue() 
{
	std::cout << "\n" << mName << " ---Received EVENT:";
	Event *e = mEventQueue.back();
	e->Dump();
	mEventQueue.pop_back();
	switch ( e->What() )
	{
		case	eAll_FIRST_HOUSE : //FirstHouse ( e ); break;
		case	eALL_UPDATE      : 
		case	et_GIVE_FLOORS   : GiveFloors( e ); 	break;
		case	et_FORCED_BUILD  : ForceBuild( e ); 	break; 
		case	et_ADD_MORE      : AddMore( e ); 	break;
		case	et_YOUR_TURN     : YourTurn (e ); 	break;
		case	et_TAKE_FROM_DECK: TakeCards( e ); 	break;
		case	et_PICK_MORE     : PickMore ( e ); 	break; 
		default:	std::cout << "Unknown event" ;  break;
	}
	mTable->Notify(e);
};

void Player::TakeCards ( int num, Card **card )
{
	std::cout<< "\n"  << mName << " ---Received cards:";
	while ( num >=0 )
	{
		mCards.push_back( card[num] );
		std::cout << (char)card[num]->GetSuit() << " " << card[num]->GetRank();
		num = num-1;
	}
	
}

void Player::GiveFloors( Event *e )
{
}
void Player::ForceBuild( Event *e )
{
}
void Player::AddMore( Event *e )
{
}
void Player::YourTurn( Event *e )
{
}
void Player::TakeCards( Event *e )
{
	std::cout << "\n" << mName << " ---Received cards  event:";
	std::vector<Card*> *card = e->GetCardList();
	while ( card->size() != 0 )
	{
		mCards.push_back( card->back() );
		std::cout << card->back()->GetSuit() << " " << card->back()->GetRank();
		card->pop_back();
	}
	return;
}
void Player::PickMore( Event *e )
{
}
